package com.jindy.module.outboundorder.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jindy.module.outboundorder.domain.OutboundOrderProduct;
import com.jindy.module.outboundorder.service.IOutboundOrderProductService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 出库单-产品Controller
 *
 * @author ruoyi
 * @date 2022-10-18
 */
@RestController
@RequestMapping("/module/outboundOrderProduct")
public class OutboundOrderProductController extends BaseController
{
    @Autowired
    private IOutboundOrderProductService outboundOrderProductService;

    /**
     * 查询出库单-产品列表
     */
//    @PreAuthorize("@ss.hasPermi('module:outboundOrderProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutboundOrderProduct outboundOrderProduct)
    {
        startPage();
        List<OutboundOrderProduct> list = outboundOrderProductService.selectOutboundOrderProductList(outboundOrderProduct);
        return getDataTable(list);
    }

    /**
     * 导出出库单-产品列表
     */
//    @PreAuthorize("@ss.hasPermi('module:outboundOrderProduct:export')")
    @Log(title = "出库单-产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OutboundOrderProduct outboundOrderProduct)
    {
        List<OutboundOrderProduct> list = outboundOrderProductService.selectOutboundOrderProductList(outboundOrderProduct);
        ExcelUtil<OutboundOrderProduct> util = new ExcelUtil<OutboundOrderProduct>(OutboundOrderProduct.class);
        util.exportExcel(response, list, "出库单-产品数据");
    }

    /**
     * 获取出库单-产品详细信息
     */
//    @PreAuthorize("@ss.hasPermi('module:outboundOrderProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(outboundOrderProductService.selectOutboundOrderProductById(id));
    }

    /**
     * 新增出库单-产品
     */
//    @PreAuthorize("@ss.hasPermi('module:outboundOrderProduct:add')")
    @Log(title = "出库单-产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutboundOrderProduct outboundOrderProduct)
    {
        return toAjax(outboundOrderProductService.insertOutboundOrderProduct(outboundOrderProduct));
    }

    /**
     * 修改出库单-产品
     */
//    @PreAuthorize("@ss.hasPermi('module:outboundOrderProduct:edit')")
    @Log(title = "出库单-产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutboundOrderProduct outboundOrderProduct)
    {
        return toAjax(outboundOrderProductService.updateOutboundOrderProduct(outboundOrderProduct));
    }

    /**
     * 删除出库单-产品
     */
//    @PreAuthorize("@ss.hasPermi('module:outboundOrderProduct:remove')")
    @Log(title = "出库单-产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(outboundOrderProductService.deleteOutboundOrderProductByIds(ids));
    }
}
